load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "util",
    srcs = [
        "cpu_posix.go",
        "cpu_windows.go",
        "errors.go",
        "etcd.go",
        "gogc.go",
        "id_generator.go",
        "misc.go",
        "prefix_helper.go",
        "printer.go",
        "processinfo.go",
        "rlimit_other.go",
        "rlimit_windows.go",
        "security.go",
        "urls.go",
        "util.go",
        "wait_group_wrapper.go",
    ],
    importpath = "github.com/pingcap/tidb/util",
    visibility = ["//visibility:public"],
    deps = [
        "//config",
        "//kv",
        "//metrics",
        "//parser",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//session/txninfo",
        "//sessionctx/stmtctx",
        "//util/collate",
        "//util/disk",
        "//util/execdetails",
        "//util/logutil",
        "//util/memory",
        "//util/tls",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_log//:log",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_tikv_client_go_v2//oracle",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_etcd_go_etcd_client_v3//concurrency",
        "@org_golang_google_grpc//:grpc",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "util_test",
    timeout = "short",
    srcs = [
        "errors_test.go",
        "main_test.go",
        "misc_test.go",
        "prefix_helper_test.go",
        "security_test.go",
        "urls_test.go",
        "util_test.go",
        "wait_group_wrapper_test.go",
    ],
    data = glob(["tls_test/**"]),
    embed = [":util"],
    flaky = True,
    shard_count = 50,
    deps = [
        "//kv",
        "//parser",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//sessionctx/stmtctx",
        "//store/mockstore",
        "//testkit/testsetup",
        "//types",
        "//util/fastrand",
        "//util/memory",
        "@com_github_pingcap_errors//:errors",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_goleak//:goleak",
    ],
)
